package com.wxb.qd.controller;


import com.wxb.qd.common.BaseResponse;
import com.wxb.qd.common.ResultUtils;
import com.wxb.qd.entity.Announcement;
import com.wxb.qd.service.AnnouncementService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * 公告控制类
 * @author wangxb
 */
@RestController
@RequestMapping("/ann")
public class AnnouncementController {

    @Resource
    private AnnouncementService announcementService;

    /**
     * 查询所有的公告信息
     * @return 所有的公告信息
     */
    @GetMapping("/all")
    public BaseResponse<List<Announcement>> getAllAnn(){
        List<Announcement> allAnn = announcementService.getAllAnn();
        return ResultUtils.success(allAnn);
    }

    /**
     * 查询单个公告
     * @param announcement 公告特征
     * @return 单个公告信息
     */
    @PostMapping("/one")
    public BaseResponse<Announcement> getOneAnn(@RequestBody Announcement announcement){
        Announcement oneAnn = announcementService.getOneAnn(announcement);
        return ResultUtils.success(oneAnn);
    }


}
